package com.yzh.wanandroid.vm

import android.app.Application
import androidx.lifecycle.LifecycleOwner
import com.yzh.core.livedata.SingleLiveEvent
import com.yzh.wanandroid.base.BaseFragmentViewModel
import com.yzh.wanandroid.model.StateData
import com.yzh.wanandroid.network.retrofit.responsebean.BaseData
import com.yzh.wanandroid.network.retrofit.responsebean.LoginData


class LoginFragmentVm(application: Application) : BaseFragmentViewModel(application) {

    private val TAG = "LoginFragmentVm"

    var mLoginData = SingleLiveEvent<StateData<BaseData<LoginData>>>()

    fun login(owner: LifecycleOwner, username: String, password: String) {
        mUserRepository.login(owner,username, password, mLoginData)
    }

    override fun onDestory(owner: LifecycleOwner) {
        super.onDestory(owner)
        mLoginData.call()
    }
}